<?php
class CV_Datastore_Metadata_Relational_Provider_Mysql_Column{
	private $_metadata;
	private $_table;
	function __construct( $metadata, $table ){
		$this->_metadata = $metadata;
		$this->_table = $table;
		$this->name = $this->_metadata['COLUMN_NAME'];
	}
	function get_table(){
		return $this->_table;
	}
	function get_name(){
		return $this->name;
	}
	function get_type(){
		return $this->_metadata['DATA_TYPE'];
	}
	function get_length(){
		if( !empty($this->_metadata['CHARACTER_MAXIMUM_LENGTH']) ){
			return $this->_metadata['CHARACTER_MAXIMUM_LENGTH'];
		} else {
			return $this->_metadata['NUMERIC_PRECISION'];			
		}
	}
	function get_default_value(){
		return $this->_metadata['COLUMN_DEFAULT'];		
	}
	function is_key(){
		return !empty( $this->_metadata['COLUMN_KEY'] );
	}
	function is_primary_key(){
		return $this->_metadata['COLUMN_KEY'] === 'PRI';
	}
	function is_current_timestamp(){
		return $this->_metadata['COLUMN_DEFAULT'] === 'CURRENT_TIMESTAMP';
	}
	function is_nullable(){
		return $this->_metadata['IS_NULLABLE'] === 'YES';
	}
}